
package com.swak.frame.dto.request;

import java.util.Date;

import javax.validation.constraints.NotNull;

import com.swak.frame.dto.base.Command;

/**
 * 
 * @ClassName: SwakRequest.java
 * @author: colley.ma
 * @date: 2022/01/25
 */
public class SwakRequest extends Command {

	private static final long serialVersionUID = 5356556951291501829L;

	/** 用户信息 **/
	protected String pin;

	@NotNull(message = "sourceCode不能为空")
	protected String sourceCode;

	/** 压测标 1=压测 **/
	protected String forcebot;

	@NotNull(message = "appId不能为空")
	protected String appId;

	@NotNull(message = "ip不能为空")
	protected String ip;

	/** 渠道Token **/
	protected String channelToken;

	/** 渠道ID **/
	protected Integer channelId;

	/** functionId **/
	protected String functionId;

	/** 穿越时间 **/
	protected Date futureTime = new Date();

	/** 是否白名单 **/
	protected boolean whiteList = false;

	/** 前端请求携带的HTTP Referer */
	protected String referer;

	/** 前端请求携带的User-Agent */
	protected String agent;
	

    /** 入参useCase */
    protected String useCase;

	public SwakRequest() {
	}

	public String getPin() {
		return pin;
	}

	public void setPin(String pin) {
		this.pin = pin;
	}

	public String getForcebot() {
		return forcebot;
	}

	public void setForcebot(String forcebot) {
		this.forcebot = forcebot;
	}

	public String getAppId() {
		return appId;
	}

	public void setAppId(String appId) {
		this.appId = appId;
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public String getChannelToken() {
		return channelToken;
	}

	public void setChannelToken(String channelToken) {
		this.channelToken = channelToken;
	}

	public Integer getChannelId() {
		return channelId;
	}

	public void setChannelId(Integer channelId) {
		this.channelId = channelId;
	}

	public String getFunctionId() {
		return functionId;
	}

	public void setFunctionId(String functionId) {
		this.functionId = functionId;
	}

	public Date getFutureTime() {
		return futureTime;
	}

	public void setFutureTime(Date futureTime) {
		this.futureTime = futureTime;
	}

	public boolean isWhiteList() {
		return whiteList;
	}

	public void setWhiteList(boolean whiteList) {
		this.whiteList = whiteList;
	}

	public String getReferer() {
		return referer;
	}

	public void setReferer(String referer) {
		this.referer = referer;
	}

	public String getAgent() {
		return agent;
	}

	public void setAgent(String agent) {
		this.agent = agent;
	}

	public String getUseCase() {
    return useCase;
  }

  public void setUseCase(String useCase) {
    this.useCase = useCase;
  }

  public static SwakRequest buildRequest(String pin, String forcebot) {
		SwakRequest request = new SwakRequest();
		request.setPin(pin);
		request.setForcebot(forcebot);
		return request;
	}

	public static SwakRequest buildRequest(String pin) {
		return SwakRequest.buildRequest(pin, null);
	}

	public static class Builder {
		private String pin;
		private String forcebot;
		private String appId;
		private String ip;
		private String channelToken;
		private Integer channelId;
		private String functionId;
		private Date futureTime;
		private boolean whiteList;
		private String referer;
		private String agent;
		private String useCase;

		public Builder useCase(String useCase) {
          this.useCase = useCase;
          return this;
      }
		
		public Builder pin(String pin) {
			this.pin = pin;
			return this;
		}

		public Builder forcebot(String forcebot) {
			this.forcebot = forcebot;
			return this;
		}

		public Builder appId(String appId) {
			this.appId = appId;
			return this;
		}

		public Builder ip(String ip) {
			this.ip = ip;
			return this;
		}

		public Builder channelToken(String channelToken) {
			this.channelToken = channelToken;
			return this;
		}

		public Builder channelId(Integer channelId) {
			this.channelId = channelId;
			return this;
		}

		public Builder functionId(String functionId) {
			this.functionId = functionId;
			return this;
		}

		public Builder futureTime(Date futureTime) {
			this.futureTime = futureTime;
			return this;
		}

		public Builder whiteList(boolean whiteList) {
			this.whiteList = whiteList;
			return this;
		}

		public Builder referer(String referer) {
			this.referer = referer;
			return this;
		}

		public Builder agent(String agent) {
			this.agent = agent;
			return this;
		}

		public SwakRequest build() {
			return new SwakRequest(this);
		}
	}

	protected SwakRequest(Builder builder) {
		this.pin = builder.pin;
		this.forcebot = builder.forcebot;
		this.appId = builder.appId;
		this.ip = builder.ip;
		this.channelToken = builder.channelToken;
		this.channelId = builder.channelId;
		this.functionId = builder.functionId;
		this.futureTime = builder.futureTime;
		this.whiteList = builder.whiteList;
		this.referer = builder.referer;
		this.agent = builder.agent;
		this.useCase = builder.useCase;
	}
}
